//
//  reloginViewController.m
//  TinyFortune
//
//  Created by lc on 16/5/27.
//  Copyright © 2016年 lc. All rights reserved.
//

#import "reloginViewController.h"

@interface reloginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameLabel;
@property (weak, nonatomic) IBOutlet UITextField *passwordLabel;
- (IBAction)loginAction:(UIButton *)sender;

@end

@implementation reloginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置导航栏
    self.navigationController.navigationBar.translucent = NO ;
    [self.navigationController setNavigationBarHidden:NO];
    UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
    [self.navigationItem setLeftBarButtonItem:left];
    self.title = @"登录";
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:86/255.0f green:202/255.0f blue:255/255.0f alpha:0.5]];
    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)cancel{
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (IBAction)loginAction:(UIButton *)sender {
   
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];
    hud.labelText = @"正在登陆";
    [AVUser logInWithMobilePhoneNumberInBackground:_nameLabel.text password:_passwordLabel.text block:^(AVUser *user, NSError *error) {
       
       if (user != nil) {
           [hud hide:YES];
           [self.navigationController dismissViewControllerAnimated:YES completion:nil];
       }else{
           [KVNProgress showErrorWithStatus:error.localizedDescription];
       }
   }];
}
@end
